import request from '@/utils/request.js'

const url = '/cloud-wkf-service/admin'
// 查询表单组
export function getFormGroups(param) {
    return request({
        url: url + '/form/group',
        method: 'get',
        params: param
    })
}

// 表单排序
export function groupItemsSort(param) {
    return request({
        url: url + '/form/group/sort',
        method: 'put',
        data: param
    })
}

// 更新表单组
export function updateGroup(param, method) {
    return request({
        url: url + '/form/group',
        method: method,
        params: param
    })
}

// 获取表单分组
export function getGroup() {
    return request({
        url: url + '/form/group/list',
        method: 'get'
    })
}

// 更新表单
export function updateForm(param) {
    return request({
        url: url + '/form',
        method: 'put',
        params: param
    })
}

export function createForm(param){
    return request({
        url: url + '/form',
        method: 'post',
        data: param
    })
}

// 查询表单详情
export function getFormDetail(id) {
    return request({
        url: url + '/form/detail/' + id,
        method: 'get',
    })
}

// 通过模板id查询表单详情 会附带流程定义id
export function detail(templateId) {
    return request({
        url: `/cloud-wkf-service/workspace/process/detail/${templateId}`,
        method: 'get',
    })
}

// 更新表单详情
export function updateFormDetail(param) {
    return request({
        url: url + '/form/detail',
        method: 'put',
        data: param
    })
}

export default {
    getFormGroups, groupItemsSort, createForm, getFormDetail,
    updateGroup, getGroup, updateForm, updateFormDetail
}
